package com.xinzhi.controller;

import com.xinzhi.model.Result;
import com.xinzhi.model.User;
import com.xinzhi.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class Usercontroller {
    @Autowired
    private IUserService userService;

    @RequestMapping(value = "/queryUsers",method = RequestMethod.GET)
    @ResponseBody
    public Result queryUsersByCondition(User user){
        List<User> users = userService.queryUserByCondition(user);
        if(users.size()!=0){
            return Result.ok(users);
        }
        return Result.error(666, "没有符合条件的数据");
    }
}
